package com.iyundao.io.mapper;

import com.iyundao.io.model.ActivityModel;

import static org.apache.ibatis.jdbc.SqlBuilder.*;

public class ActivityModelSqlProvider {

    public String insertSelective(ActivityModel record) {
        BEGIN();
        INSERT_INTO("activitymodel");
        
        if (record.getId() != null) {
            VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getActivitytitle() != null) {
            VALUES("activitytitle", "#{activitytitle,jdbcType=VARCHAR}");
        }
        
        if (record.getActivitycontent() != null) {
            VALUES("activitycontent", "#{activitycontent,jdbcType=VARCHAR}");
        }
        
        if (record.getActivitystarttime() != null) {
            VALUES("activitystarttime", "#{activitystarttime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getActivityendtime() != null) {
            VALUES("activityendtime", "#{activityendtime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getActivitysignstarttime() != null) {
            VALUES("activitysignstarttime", "#{activitysignstarttime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getActivitysignendtime() != null) {
            VALUES("activitysignendtime", "#{activitysignendtime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getActivitylongitude() != null) {
            VALUES("activitylongitude", "#{activitylongitude,jdbcType=DOUBLE}");
        }
        
        if (record.getActivitylatitude() != null) {
            VALUES("activitylatitude", "#{activitylatitude,jdbcType=DOUBLE}");
        }
        
        if (record.getActivitysitename() != null) {
            VALUES("activitysitename", "#{activitysitename,jdbcType=VARCHAR}");
        }
        
        if (record.getActivitycreatetime() != null) {
            VALUES("activitycreatetime", "#{activitycreatetime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getActivitynumber() != null) {
            VALUES("activitynumber", "#{activitynumber,jdbcType=INTEGER}");
        }
        
        if (record.getActivityjoinnumber() != null) {
            VALUES("activityjoinnumber", "#{activityjoinnumber,jdbcType=INTEGER}");
        }
        
        if (record.getActivityintegral() != null) {
            VALUES("activityintegral", "#{activityintegral,jdbcType=INTEGER}");
        }
        
        if (record.getActivityimg() != null) {
            VALUES("activityimg", "#{activityimg,jdbcType=VARCHAR}");
        }
        
        if (record.getUserid() != null) {
            VALUES("userid", "#{userid,jdbcType=VARCHAR}");
        }
        
        if (record.getActivityflag() != null) {
            VALUES("activityflag", "#{activityflag,jdbcType=INTEGER}");
        }
        
        if (record.getActivityid() != null) {
            VALUES("activityid", "#{activityid,jdbcType=INTEGER}");
        }
        
        if (record.getActivitydigest() != null) {
            VALUES("activitydigest", "#{activitydigest,jdbcType=VARCHAR}");
        }
        
        if (record.getOrganizationid() != null) {
            VALUES("organizationid", "#{organizationid,jdbcType=VARCHAR}");
        }
        
        return SQL();
    }

    public String selectAll(ActivityModel record) {
        BEGIN();
        SELECT("id, activitytitle, activitycontent, activitystarttime, " +
                "activityendtime, activitysignstarttime, activitysignendtime, " +
                "activitylongitude, activitylatitude, activitysitename, activitycreatetime, " +
                "activitynumber, activityjoinnumber, activityintegral, activityimg, userid, " +
                "activityflag, activityid, activitydigest, organizationid");
        WHERE("activityflag=1");
        return SQL();
    }

    public String selectAllByOrganizationId(String organizationid) {
        BEGIN();
        SELECT("id, activitytitle, activitycontent, activitystarttime, " +
                "activityendtime, activitysignstarttime, activitysignendtime, " +
                "activitylongitude, activitylatitude, activitysitename, activitycreatetime, " +
                "activitynumber, activityjoinnumber, activityintegral, activityimg, userid, " +
                "activityflag, activityid, activitydigest, organizationid");
        WHERE("activityflag=1 and organizationid=#{organizationid,jdbcType=VARCHAR}");
        return SQL();
    }
}